<?php
require_once $_SERVER['DOCUMENT_ROOT']."/../_lib/base/common.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.template.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.hotels.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.tree.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.hotel_instances_you.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.exchange_rates.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.airports.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.photos.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.suppliers.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.lurls.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.destinations.php";
// New Classes
require_once SITE_ROOT_PATH."/_lib/classes/class.hotel_search.php";
require_once SITE_ROOT_PATH."/_lib/classes/controller/SearchHotelController.php";

//session_start();

if($_GET['sid']){
    session_id($_REQUEST['sid']);  
    session_start();
}else{
    session_start();
}

$searchHotelController = new SearchHotelController();

$opa = $searchHotelController->executeActionSearch($_POST, (count($_POST) ? true : false ));
/**
 *This code was put here just to avoid that the session lost some variables after header
 * (I don't know yet what excatcly was happening it, but this code is working) 
 */
try {
     session_write_close();
     header("Location: results.php?sid=".session_id()  );
     exit();
} catch (Exception $exc) {
    header("Location: results.php?sid=".session_id()  );
    exit();
    
} 
    
?>